<?php
/*-------------------------------------------------------------------------\
|
|  ========================================================
|  Fusion Registry GPL
|  Copyright (C) 2007 Fusion Scripts
|
|  This program is free software; you can redistribute it and/or
|  modify it under the terms of the GNU General Public License
|  as published by the Free Software Foundation; either version 2
|  of the License, or (at your option) any later version.
|
|  This program is distributed in the hope that it will be useful,
|  but WITHOUT ANY WARRANTY; without even the implied warranty of
|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|  GNU General Public License for more details.
|
|  You should have received a copy of the GNU General Public License
|  along with this program; if not, write to the Free Software
|  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
|  ========================================================
|
|  Email: info@fusionscripts.com
|  Web-Site: http://www.fusionscripts.com/
|
|  $Id: template.php 4 2008-08-03 01:43:03Z registry.fusion $
|
\-------------------------------------------------------------------------*/

/**
 * Installation template class
 *
 * @package Fusion Registry
 * @subpackage installer
 * @version $Id: template.php 4 2008-08-03 01:43:03Z registry.fusion $
 */
class template
{
    var $contents = '';

    /**
     * Add footer and print to the screen
     */
	function output()
	{
        $this->contents .= $this->print_footer();

		echo $this->contents;

		exit();
	}
	

    /**
     * Start the html
     */
	function print_header($opts=array())
	{
        // Default options
        $bits = array( 'title' => 'Fusion Scripts Installer',
                       'current_step' => 'Welcome!',
                       'header' => 'Fusion Registry Installer '.FR_VERSION_SHORT,
                     );

        // Override defaults
        if ( is_array($opts) )
        {
            foreach ( $opts as $name => $value )
            {
                $bits[$name] = $value;
            }
        }

        $this->contents .= <<<HTML
<html>
<head>
    <title>{$bits['title']}</title>
    <style type='text/css'>
        td {
            text-align: left;
            vertical-align: top;
            font-family:Arial;
            font-size:12px;
            color:#6B6B6B;
            line-height:13px;
        }

        a {
            text-decoration: underline;
            color:#3082A8;
            font-size:11px;
        }

        body { 
            margin: 0px;
            padding: 0px;
            line-height: 135%;
        }

        .copy {
            font-family:Tahoma;
            font-size:11px;
            color:#6B6B6B;
            text-decoration:none;
        }

        .content_body {
            line-height: 1.3;
            margin-left:11px;
            margin-top:20px;
            margin-bottom:20px;
            width:649px;
        }

        .page_header {
            text-align: left;
            vertical-align: middle;
            font-weight: bold;
            padding-top:7px;
            margin-left:11px;
        }

        a:hover { text-decoration:underline; }

        html,body { height: 100%; }

        img{ border: 0; }

        #current_step {
            margin-top: 51px;
            margin-left: 2px;
            font-family: Arial,Verdana,Tahoma;
            font-size: 30px;
            text-align: right;
            font-weight: bold;
        }

        .button {
            background: #FFCC00;
            border: 1px solid #003366;
            font-size: 11px;
            font-weight: bold;
            padding: 4px;
          	vertical-align: middle;
            font-family: Verdana, Helvetica, Sans-Serif;
            text-decoration: none;
            line-height: 135%;
        }

        .check_row { line-height: 135%; background: #EBEBEB; }

        .fail_txt {
            color: red;
            font-weight: bold;
        }

        .fail {
            background: red;
            color: white;
            text-align: center;
            vertical-align: middle;
            font-weight: bold;
            font-family: Tahoma;
        }

        .notice_txt {
            color: blue;
            font-weight: bold;
        }

        .notice {
            background: blue;
            color: white;
            text-align: center;
            vertical-align: middle;
            font-weight: bold;
        }

        .pass_txt {
            color: green;
            font-style: italic;
        }

        .pass {
            background: green;
            color: white;
            text-align: center;
            vertical-align: middle;
            font-weight: bold;
        }

        .warnbox {
            border:1px solid #F00;
            background: #FFE0E0;
            padding: 6px;
            margin-right: 10%;
            margin-left: 10%;
            text-align: left;
         }
    </style>
</head>

<body BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<TABLE WIDTH=100% height="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
    <TR>
        <TD width="50%" background="img/left_bg.jpg" style="background-position:right; background-repeat:repeat-y " bgcolor="#CFCFCF"><IMG SRC="img/spacer.gif" WIDTH=17 HEIGHT=637 ALT=""></TD>
        <TD WIDTH=731 ALT="" valign="top">
            <TABLE WIDTH=731 BORDER=0 CELLPADDING=0 CELLSPACING=0>
                <TR>
                    <TD WIDTH=731 ALT="" valign="top">
                        <TABLE WIDTH=731 BORDER=0 CELLPADDING=0 CELLSPACING=0>
                            <TR>
                                <TD ROWSPAN=2 WIDTH=217 ALT="" valign="top">
                                    <TABLE WIDTH=217 BORDER=0 CELLPADDING=0 CELLSPACING=0>
                                        <TR><TD COLSPAN=3><IMG SRC="img/company.jpg" WIDTH=217 HEIGHT=92 ALT=""></TD></TR>
                                    </TABLE>
                                </TD>
                                <TD WIDTH=490 HEIGHT=90 ALT="" valign="top">
                                    <div id="current_step">
                                        {$bits['current_step']}
                                    </div>
                                </TD>
                                <TD ROWSPAN=2><IMG SRC="img/spacer.gif" WIDTH=24 HEIGHT=92 ALT=""></TD>
                            </TR>
                        </TABLE>
                    </TD>
                </TR>
                <TR>
                    <TD WIDTH=731 HEIGHT=248 ALT="" valign="top">
                        <table width="731" height="248" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="26"><img src="img/spacer.gif"></td>
                                <td width="681" valign="top">
                                    <table width="681" height="248" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td width="681" valign="top">
                                                <div style="padding-top:15px;"> </div>
                                                <div style="height:28px; background-image:url(img/px.jpg) "><div class="page_header">{$bits['header']}</div></div>
                                                <div style="margin-top:14px;margin-bottom:14px; ">
                                                    <table width="681" height="90" border="0" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td width="354" valign="top">
                                                                <div class="content_body">
HTML;
        return TRUE;
    }


    /**
     * Finish off the template and add the copyright
     */
    function print_footer()
    {
        $year = date('Y');

        $this->contents .= <<<HTML
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="24"><img src="img/spacer.gif"></td>
                            </tr>
                        </table>
                    </TD>
                </TR>
                <TR>
                    <TD WIDTH=731 HEIGHT=100% ALT="" valign="top">
                        <table width="731" height="104" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="26"><img src="img/spacer.gif"></td>
                                <td width="681" valign="top" background="img/bot_px.jpg" style="background-position:top; background-repeat:repeat-x ">
                                    <div align="center" style="margin-top:17px " class="copy"><a href="http://www.fusionscripts.com" target="_blank" style="text-decoration:none">Fusion Registry GPL</a></div>
                                </td>
                                <td width="24"><img src="img/spacer.gif"></td>
                            </tr>
                        </table>
                    </TD>
                </TR>
            </TABLE>
        </TD>
        <TD width="50%" background="img/right_bg.jpg" style="background-position:left; background-repeat:repeat-y " bgcolor="#CFCFCF"><IMG SRC="img/spacer.gif" WIDTH=18 HEIGHT=637 ALT=""></TD>
    </TR>
</TABLE>
</BODY>
</HTML>
HTML;
        return TRUE;
    }


    /**
     * Build fail html
     */
    function check_fail($opts=array())
    {
        $html = "<tr><td class='check_row'>".$opts['check']." ... <br /><br /><span class='fail_txt'>".$opts['message']."</span></td><td class='fail'>FAIL</td></tr>";

        return $html;
    }


    /**
     * Build notice html
     */
    function check_notice($opts=array())
    {
        $html = "<tr><td class='check_row'>".$opts['check']." ...<br /><br /><span class='notice_txt'>".$opts['message']."</span></td><td class='notice'>NOTICE</td></tr>";

        return $html;
    }


    /**
     * Build pass html
     */
    function check_pass($opts=array())
    {
        $html = "<tr><td class='check_row'>".$opts['check']." ... <span class='pass_txt'>".$opts['message']."</span></td><td class='pass'>PASS</td></tr>";

        return $html;
    }


    /**
     * Formatted error message
     */
    function install_error($msg="")
    {
        $this->print_header( array( 'current_step' => 'Warning!' ) );
        
        $this->contents .= "<div class='warnbox'>
                             <strong style='font-size:16px;color:#F00'>Warning!</strong>
                             <br /><br />
                             <b>The following error(s) must be fixed before continuing!</b><br>Please go back and try again!
                             <br /><br />
                             $msg
                            </div>";

        $this->output();
    }
}
?>